<?php

namespace App\Util;

use App\Enum\Facilities;
use App\Enum\NetWork;

class ExplodeHelper {

    public static function enumToChn($str) {
        $temp = [];
        $string = '';
        $arr = explode(',', $str);
        foreach ($arr as $v) {
            $temp[] = Facilities::getLabel($v);
        }
        foreach ($temp as $v) {
            $string .= $v.'、';
        }
        $string = mb_substr($string, 0, -1);
        return $string;
    }

    public static function explodeToStr($str) {
        $string = '';
        $arr = explode(',', $str);
        foreach ($arr as $v) {
            $string .= $v . '-';
        }
        $string = substr($string, 0, -1);
        return $string;
    }

    public static function explodeNetWork($str) {
        $temp = [];
        $string = '';
        $arr = explode(',', $str);
        foreach ($arr as $v) {
            $temp[] = NetWork::getLabel($v);
        }
        foreach ($temp as $v) {
            $string .= $v.'、';
        }
        $string = mb_substr($string, 0, -1);
        return $string;
    }

}